package com.sphd.beautysalon.model;


import com.android.volley.VolleyError;
import com.sphd.beautysalon.base.BaseModel;
import com.sphd.beautysalon.interfaces.VolleyJsonObjectCallBack;
import com.sphd.beautysalon.presenter.AddCouponPresenterImpl;

import org.json.JSONException;
import org.json.JSONObject;

/**
* Created by Hu on 2016/12/20
*/

public class AddCouponModelImpl implements AddCouponModel, VolleyJsonObjectCallBack {
    AddCouponPresenterImpl addCouponPresenter;
    @Override
    public void sendUrl(String url, AddCouponPresenterImpl addCouponPresenter) {
        this.addCouponPresenter=addCouponPresenter;
        BaseModel.volleyUtil.setJsonObjectRequest(url,this);
    }

    @Override
    public void onResponse(JSONObject response) {
        try {
            int res =response.getInt("res");
            addCouponPresenter.sendRes(res);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onErrorResponse(VolleyError error) {

    }
}